| @@ -17,7 +17,7 @@ class AdminPanelController < ApplicationController | ||
| 17 | 17 | end | 
| 18 | 18 |  | 
| 19 | 19 | def contact_messages | 
| 20 | - @contact_messages = ContactMessage.all | |
| 20 | +    @contact_messages = ContactMessage.order('created_at DESC').all | |
| 21 | 21 | end | 
| 22 | 22 |  | 
| 23 | 23 | def users | 
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | class ContactMessagesController < ApplicationController | 
| 2 | - before_action :set_contact_message, only: [:show, :edit, :update, :destroy] | |
| 2 | + before_action :set_contact_message, only: [:show, :edit, :update, :destroy, :unread, :readed] | |
| 3 | 3 |  | 
| 4 | 4 | # GET /contact_messages | 
| 5 | 5 | # GET /contact_messages.json | 
| @@ -26,6 +26,37 @@ class ContactMessagesController < ApplicationController | ||
| 26 | 26 | end | 
| 27 | 27 | end | 
| 28 | 28 |  | 
| 29 | + def show | |
| 30 | + @contact_message.unread = false | |
| 31 | + @contact_message.save | |
| 32 | + end | |
| 33 | + | |
| 34 | + def readed | |
| 35 | + @contact_message.unread = false | |
| 36 | + respond_to do |format| | |
| 37 | + if @contact_message.save | |
| 38 | +        format.html { redirect_to admin_contact_messages_path, notice: 'Contact message marked as readed.' } | |
| 39 | +        format.json { render action: 'show', status: :created, location: @contact_message } | |
| 40 | + else | |
| 41 | +        format.html { render action: 'new' } | |
| 42 | +        format.json { render json: @contact_message.errors, status: :unprocessable_entity } | |
| 43 | + end | |
| 44 | + end | |
| 45 | + end | |
| 46 | + | |
| 47 | + def unread | |
| 48 | + @contact_message.unread = true | |
| 49 | + respond_to do |format| | |
| 50 | + if @contact_message.save | |
| 51 | +        format.html { redirect_to admin_contact_messages_path, notice: 'Contact message marked as unread.' } | |
| 52 | +        format.json { render action: 'show', status: :created, location: @contact_message } | |
| 53 | + else | |
| 54 | +        format.html { render action: 'new' } | |
| 55 | +        format.json { render json: @contact_message.errors, status: :unprocessable_entity } | |
| 56 | + end | |
| 57 | + end | |
| 58 | + end | |
| 59 | + | |
| 29 | 60 | # PATCH/PUT /contact_messages/1 | 
| 30 | 61 | # PATCH/PUT /contact_messages/1.json | 
| 31 | 62 | def update | 
| @@ -8,19 +8,32 @@ | ||
| 8 | 8 | <% @contact_messages.each do |msg| %> | 
| 9 | 9 | <div class="media thumbnail" style="padding: 10px; padding-bottom: 5px;"> | 
| 10 | 10 | <div class="media-body pull-left"> | 
| 11 | - <h3 class="media-heading" style="margin-bottom: 0px;"><%= link_to msg.title, contact_message_path(msg) %> | |
| 12 | -			    <%= ('<span class="badge badge-warning" style="margin-top: -11px">' + (t "admin_panel.new") + '</span>').html_safe if msg.unread %></h3> | |
| 13 | - <p style="margin-top: -5px;"><small><%= t "blog.by" %> | |
| 11 | + <h4 class="media-heading" style="margin-bottom: 0px;"> | |
| 12 | +			    <%= ('<span class="badge badge-warning" style="margin-top: -11px">' + (t "admin_panel.new") + '</span>').html_safe if msg.unread %> | |
| 13 | + <%= link_to msg.title, contact_message_path(msg) %> | |
| 14 | + | |
| 15 | + <span style="margin-top: -5px;"><small><%= t "contact.by" %> | |
| 14 | 16 | <% if msg.user != nil %> | 
| 15 | 17 | <%= msg.user.full_name %> | 
| 16 | 18 | <% else %> | 
| 17 | 19 | <%= msg.email %> | 
| 18 | 20 | <% end %> | 
| 19 | 21 | , <%= time_ago_in_words(msg.created_at) %> <%= t "blog.ago" %> | 
| 20 | - </small></p> | |
| 21 | - <p><%= msg.content %></p> | |
| 22 | - </div> | |
| 23 | - </div> | |
| 22 | + </small></span> | |
| 23 | + </h4> | |
| 24 | + <p style="margin-top: 15px;"><%= truncate( msg.content, length: 120, omission: '...') %></p> | |
| 25 | + </div> | |
| 26 | + <div class="pull-right"> | |
| 27 | + <div class="btn-group btn-group-vertical"> | |
| 28 | + <% if msg.unread %> | |
| 29 | + <%= link_to '<i class="icon-eye-open"></i>'.html_safe, mark_contact_message_as_readed_path(msg), :class => 'btn' %> | |
| 30 | + <% else %> | |
| 31 | + <%= link_to '<i class="icon-eye-close"></i>'.html_safe, mark_contact_message_as_unread_path(msg), :class => 'btn' %> | |
| 32 | + <% end %> | |
| 33 | +  		      	<%= link_to '<i class="icon-remove"></i>'.html_safe, msg, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-danger' %> | |
| 34 | + </div> | |
| 35 | + </div> | |
| 36 | + </div> | |
| 24 | 37 | <% end %> | 
| 25 | 38 |  | 
| 26 | 39 | </div> | 
| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | <div class="media thumbnail" style="padding: 10px; padding-bottom: 5px;"> | 
| 10 | 10 | <span class="pull-left"> | 
| 11 | 11 | <% if user.avatar.file != nil %> | 
| 12 | - <%= image_tag user.avatar.thumb.to_s %> | |
| 12 | + <%= image_tag user.avatar.thumb.to_s, :class => 'img-circle' %> | |
| 13 | 13 | <% else %> | 
| 14 | - <%= image_tag "user.png", size: "50x50" %> | |
| 14 | + <%= image_tag "user.png", size: "50x50", :class => 'img-circle' %> | |
| 15 | 15 | <% end %> | 
| 16 | 16 | </span> | 
| 17 | 17 | <div class="media-body pull-left" style="min-width: 180px;"> | 
| @@ -242,4 +242,5 @@ en: | ||
| 242 | 242 | title: Message Title | 
| 243 | 243 | message: Message | 
| 244 | 244 | send: Send | 
| 245 | - error: Please correct the following errors | |
| 245 | + error: Please correct the following errors | |
| 246 | + by: by | 
| @@ -244,4 +244,5 @@ pt-BR: | ||
| 244 | 244 | title: Assunto | 
| 245 | 245 | message: Mensagem | 
| 246 | 246 | send: Enviar | 
| 247 | - error: Favor corrigir os erros abaixo | |
| 247 | + error: Favor corrigir os erros abaixo | |
| 248 | + by: por | 
| @@ -8,6 +8,8 @@ RailsWebsiteTemplate::Application.routes.draw do | ||
| 8 | 8 | get "admin" => "admin_panel#index" | 
| 9 | 9 | get "admin/posts" => "admin_panel#posts", :as => :admin_posts | 
| 10 | 10 | get "admin/contact_messages" => "admin_panel#contact_messages", :as => :admin_contact_messages | 
| 11 | + get "contact_message/:id/mark_contact_message_as_readed" => "contact_messages#readed", :as => :mark_contact_message_as_readed | |
| 12 | + get "contact_message/:id/mark_contact_message_as_unread" => "contact_messages#unread", :as => :mark_contact_message_as_unread | |
| 11 | 13 | get "admin/users" => "admin_panel#users", :as => :admin_users | 
| 12 | 14 | get "admin/config" => "admin_panel#site_config", :as => :admin_config | 
| 13 | 15 | post "admin/config/update" => "admin_panel#site_config_update", :as => :config_update |